package com.fzg.controller;


import com.fzg.common.enums.ResponseWrapper;
import com.fzg.common.model.param.blog.AddOrEditBlogParam;
import com.fzg.common.model.param.blog.CommentPublishBlogParam;
import com.fzg.common.model.param.diary.GetDiaryListParam;
import com.fzg.service.BlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author fzg
 * @since 2022-06-20
 */
@RestController
@RequestMapping("/blog")
public class BlogController {

    @Autowired
    private BlogService blogService;


    /**
     * @name 方法名：getMyselfBlogList
     * @description todo: 获取自己的博客列表
     * 
     * @param request 参数：HttpServletRequest
     * @param param   参数：param
     * @return ResponseWrapper
     * @date 2022/12/26 11:43
     * @author fzg
     **/
    @GetMapping("/getMyselfBlogList")
    public ResponseWrapper getMyselfBlogList(HttpServletRequest request, GetDiaryListParam param){
        return blogService.getMyselfBlogList(request,param);
    }


    /**
     * @name 方法名：getBlogListByUserAid
     * @description todo: 通过用户aid查询博客列表
     *
     * @param userAid 用户aid
     * @return ResponseWrapper
     * @date 2022/12/26 11:47
     * @author fzg
     **/
    @GetMapping("/getBlogListByUserAid")
    public ResponseWrapper getBlogListByUserAid(@RequestParam Integer userAid){
        return blogService.getBlogListByUserAid(userAid);
    }


    /**
     * @name 方法名：getAllBlogInfoByUserAid
     * @description todo: 根据博客aid查询博客相关所有信息（包括博客，评论等）
     *
     * @param request 参数：HttpServletRequest
     * @param blogAid 参数：博客aid
     * @return ResponseWrapper
     * @date 2022/12/26 11:48
     * @author fzg
     **/
    @GetMapping("/getBlogAllInfoByAid")
    public ResponseWrapper getAllBlogInfoByUserAid(HttpServletRequest request,@RequestParam Integer blogAid){
        return blogService.getAllBlogInfoByUserAid(request,blogAid);
    }


    /**
     * @name 方法名：dianzanBlog
     * @description todo: 当前登陆的用户给这条博客点赞
     *
     * @param request 参数：HttpServletRequest
     * @param aid 参数：博客aid
     * @return ResponseWrapper
     * @date 2022/12/26 11:56
     * @author fzg
     **/
    @PostMapping("/dianzanBlog")
    public ResponseWrapper dianzanBlog(HttpServletRequest request, @RequestParam Integer aid){
        return blogService.dianzanBlog(request,aid);
    }


    /**
     * @name 方法名：cancelDianzanBlog
     * @description todo: 当前登陆用户给这条博客取消点赞
     *
     * @param request 参数：HttpServletRequest
     * @param aid 参数：博客aid
     * @return ResponseWrapper
     * @date 2022/12/26 12:00
     * @author fzg
     **/
    @PostMapping("/cancelDianzanBlog")
    public ResponseWrapper cancelDianzanBlog(HttpServletRequest request,Integer aid){
        return blogService.cancelDianzanBlog(request,aid);
    }


    /**
     * @name 方法名：clickCommentLike
     * @description todo: 点击评论里面的赞，改变赞的状态
     *
     * @param request 参数：HttpServletRequest
     * @param aid 参数：评论aid
     * @return ResponseWrapper
     * @date 2022/12/26 13:10
     * @author fzg
     **/
    @PostMapping("/clickCommentLike")
    public ResponseWrapper clickCommentLike(HttpServletRequest request,Integer aid){
        return blogService.clickCommentLike(request,aid);
    }



    /**
     * @name 方法名：blogCommentPublish
     * @description todo: 发表评论
     *
     * @param request 参数：HttpServletRequest
     * @param param 参数类：CommentPublishBlogParam
     * @return ResponseWrapper
     * @date 2022/12/26 13:12
     * @author fzg
     **/
    @PostMapping("/blogCommentPublish")
    public ResponseWrapper blogCommentPublish(HttpServletRequest request, @RequestBody CommentPublishBlogParam param){
        return blogService.blogCommentPublish(request,param);
    }


    /**
     * @name 方法名：collectBlog
     * @description todo: 点击收藏，收藏这个博客
     *
     * @param request 参数：HttpServletRequest
     * @param blogAid 参数：博客aid
     * @return ResponseWrapper
     * @date 2022/12/26 14:09
     * @author fzg
     **/
    @PostMapping("/currentUserCollectCurrentBlog")
    public ResponseWrapper collectBlog(HttpServletRequest request,@RequestParam  Integer blogAid){
        return blogService.collectBlog(request,blogAid);
    }

    /**
     * 点击取消收藏这个博客
     * @return ResponseWrapper
     */
    @PostMapping("/userCancelCollectBlog")
    public ResponseWrapper cancelCollectBlog(HttpServletRequest request,@RequestParam  Integer blogAid){
        return blogService.cancelCollectBlog(request,blogAid);
    }

    /**
     * 关注这个博客的作者
     * @return ResponseWrapper
     */
    @PostMapping("/guanzhuBlogAuthor")
    public ResponseWrapper guanzhuBlogAuthor(HttpServletRequest request,@RequestParam  Integer blogAid){
        return blogService.guanzhuBlogAuthor(request,blogAid);
    }

    /**
     * 取消关注这个博客的作者
     * @return ResponseWrapper
     */
    @PostMapping("/cancelGuanzhuBlogAuthor")
    public ResponseWrapper cancelGuanzhuBlogAuthor(HttpServletRequest request,@RequestParam  Integer blogAid){
        return blogService.cancelGuanzhuBlogAuthor(request,blogAid);
    }

    /**
     * 添加或者编辑博客
     * @return ResponseWrapper
     */
    @PostMapping("/addOrEditBlog")
    public ResponseWrapper addOrEditBlog(HttpServletRequest request,@RequestBody AddOrEditBlogParam param){
        return blogService.addOrEditBlog(request, param);
    }

    /**
     * 获取系统给当前登陆的用户推荐的所有日记列表
     * @return ResponseWrapper
     */
    @GetMapping("/getRecommentBlogList")
    public ResponseWrapper getRecommentBlogList(HttpServletRequest request){
        return blogService.getRecommentBlogList(request);
    }

    /**
     * 获取当前登陆这个用户关注的所有用户的所有博客列表
     * @return ResponseWrapper
     */
    @GetMapping("/getCurrentUserConcernUserBlogList")
    public ResponseWrapper getCurrentUserConcernUserBlogList(HttpServletRequest request){
        return blogService.getCurrentUserConcernUserBlogList(request);
    }

}
